using System;

namespace Dbam.DbFramework
{
	/// <summary>
	/// Attribute that specifies the child mapping for an entity.
	/// </summary>
	[AttributeUsage(AttributeTargets.Property, AllowMultiple=false, Inherited=true)]
	public class ChildColumnMappingAttribute
		: Attribute
	{
		#region Data Members

		/// <summary>
		/// The name of the parent column in the mapping.
		/// </summary>
		private string _parentColumnName;

		/// <summary>
		/// The name of the child column to map to.
		/// </summary>
		private string _childColumnName;

		/// <summary>
		/// The type of the child entity.
		/// </summary>
		private Type _childEntityType;

		#endregion

		#region Constructor(s)

		/// <summary>
		/// Initialize the parent-child mapping.
		/// </summary>
		/// <param name="parentColumnName">The name of the parent column in the mapping.</param>
		/// <param name="childColumnName">The name of the child column in the mapping.</param>
		/// <param name="childEntityType">The child entity type.</param>
		public ChildColumnMappingAttribute(string parentColumnName, string childColumnName, Type childEntityType)
		{
			_parentColumnName = parentColumnName;
			_childColumnName = childColumnName;
			_childEntityType = childEntityType;
		}

		#endregion

		#region Properties

		/// <summary>
		/// Gets the parent column name in the mapping.
		/// </summary>
		public string ParentColumnName
		{
			get { return _parentColumnName; }
		}

		/// <summary>
		/// Gets the child column name in the mapping.
		/// </summary>
		public string ChildColumnName
		{
			get { return _childColumnName; }
		}

		/// <summary>
		/// Gets the type of the child entities this mapping will use.
		/// </summary>
		public Type ChildEntityType
		{
			get { return _childEntityType; }
		}

		#endregion
	}
}